<html>

<head>
    <meta charset="utf-8">
    <title>{$data['title']}</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="stylesheet" type="text/css" href="__HOME__/css/public.css" />
    <link rel="stylesheet" type="text/css" href="__HOME__/css/article.css" />
    <script type="text/javascript" src="__HOME__/js/jquery.js"></script>
    <script type="text/javascript">
        var user_id = "{$Think.session.user.uid}";
		console.log(user_id);
    </script>
</head>

<body>
    <!-- 分享弹框提示 start-->
  <style type="text/css">


    #cover{display:none;position:absolute;left:0;top:0;z-index:100;background-color:#000000;opacity:0.7;}

    #guide{display:none;position:fixed;right:18px;top:5px;z-index:19999;}

    #guide img{width:260px;height:180px;}



  </style>



<script type="text/javascript">

    var _system={

        $:function(id){return document.getElementById(id);},

   _client:function(){

      return {w:document.documentElement.scrollWidth,h:document.documentElement.scrollHeight,bw:document.documentElement.clientWidth,bh:document.documentElement.clientHeight};

   },

   _scroll:function(){

      return {x:document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft,y:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop};

   },

   _cover:function(show){

      if(show){

     this.$("cover").style.display="block";

     this.$("cover").style.width=(this._client().bw>this._client().w?this._client().bw:this._client().w)+"px";

     this.$("cover").style.height=(this._client().bh>this._client().h?this._client().bh:this._client().h)+"px";

  }else{

     this.$("cover").style.display="none";

  }

   },

   _guide:function(click){

      this._cover(true);

      this.$("guide").style.display="block";

      this.$("guide").style.top=(5)+"px";

      window.onresize=function(){_system._cover(true);_system.$("guide").style.top=(5)+"px";};

      if(click){_system.$("cover").onclick=function(){

             _system._cover();

             _system.$("guide").style.display="none";

         _system.$("cover").onclick=null;

         window.onresize=null;

      };}

    },

   _zero:function(n){

      return n<0?0:n;

   }

}

</script>
<div id="cover"></div>

<div id="guide"><img src="__HOME__/images/guide.png"></div>
<!-- 分享弹框提示 end-->
    <div style="padding:1rem;">
        <div>
            <p class="title">{$data['title']}</p>
			<input type='hidden' name='aid' id="aid" value="{$data['aid']}" />
            <p class="article_message">
                <span class="author">{$data['author']}</span>
                <span class="publish_time">{$data['add_time']|date="Y-n-d",###}</span>
            </p>
        </div>
        <div class="content">
            <p>{$data['content']}</p>
            <img src="{$data['img']}">
        </div>
    </div>

    <div class="bg_gray"></div> 
    <div id="comments-list">
        <div class="comments-list detail-info">
            <div class="con">
                <h3 class="hd">
                    <span class="text">全部评论</span>
                </h3> 
                <div class="comment-item mb-line-b ">
                
                    <div class="comment-detail">
                        <div class="comment">
                        <foreach name="CommentData" item="v">
                            <div class="user">
                                <div class="user-pic">
                                  <img src="{$v['img']}" class="pic">
                                </div> 
                                  <div class="user-info">
                                    <div class="username">{$v['nickname']}</div>
                                    <div class="more-info">
                                      <span>{$v['createtime']}</span>
									  
                                    </div>
                                    <div style="margin-top: 5px;">{:replace_phiz($v['content'])}</div>
                                  </div>
                                </div>
                                </foreach>
                            </div> 
                    </div>
                    
                </div> 
            </div>
        </div>
    </div>
    <div class="edit clearfix">
        <div class="input">
            
            <input class="text" onclick="showTextarea();" placeholder="写评论..." type="text" value="">
            
            <span class="icon_pen"></span>
            
        </div>
        <span class="fr" onclick="_system._guide(true)"><img src="__HOME__/images/icon/icon_share.png"></span>
        <span class="icon_zan fr" >
            <!--{$data['status']}==-->
            <if condition="$status == 0">
         <img onclick="zan()" src="__HOME__/images/icon/icon_zan_default.png"/>
         <else />
            <img   src="__HOME__/images/icon/icon_zan.png"/>
        </if> 
        <!-- {$status}=== -->
        <a id="zan_num">{$data['praise']}</a></span>
        <span class="fr"><a href="#comments-list"><img src="__HOME__/images/icon/icon_message.png"></a>{$Counts}</span>
    </div>
    <div class="edit_textarea">
        <div class="textarea_head">
            <p class="clearfix">
                <span class="fl" onclick="cancel();">取消</span>
                <span class="fr color_blue" onclick="commit();">发表</span>
            </p>
        </div>
        <div>
            <textarea rows="4" class="textarea_content"></textarea>
			<input type="hidden" class="uid" value =" {$Think.session.user.uid}" />
        </div>
    </div>
</body>

</html>
<script type="text/javascript">
   var uid = $(".uid").val();
   var aid={$data['aid']};
console.log(uid>0);
   function showTextarea(){
		if( uid>0)
		{
			 $(".edit").hide();
			$(".edit_textarea").show();
			_system._cover(true);
			setTimeout(function(){  
				document.body.scrollTop = document.body.scrollHeight;  
			},300);
		}else{
			alert("请登录");
			return;
		}
       
   }
   function cancel(){
        $(".edit_textarea").hide();
        $(".edit").show();
        _system._cover(false);
   }
   function commit(){
        $(".edit_textarea").hide();
		$(".edit").show();
	var textarea_content=$(".textarea_content").val();
	$.ajax({
	   type: "post",
	   url: "/Comments/send_comment",
	   data: {"comment":textarea_content,"uid":uid,"aid":aid},
	   dataType: "json",
	   success: function(data){
			if(data.status)
			{
				//评论成功刷新原页面，此处应该前段js处理，用刷新实现一样效果
				window.location.reload();
			}
		}
	   });
   }
   
   console.log(aid);
   function zan(){
       $.ajax({
           type : "post",
           url:"/Article/praise",
		   data: {"uid":uid, "aid":aid},
           dataType:'json',
           success: function(data)
           {
               // var data=JSON.parse(data);
               if(data.status===1){
                   $(".icon_zan img").attr('src',"/Public/home/images/icon/icon_zan.png");
                   var num=parseInt($("#zan_num").html())+1;
                   console.log(data);
                   $("#zan_num").html(num);
                    
               }else if(data.status===0){
                  console.log(data);
               }

			   
           }
       });
   }

</script>